import math
import random
import transpositionEncrypt
import unittest


class Test(unittest.TestCase):

    def setUp(self):
        print("*" * 30)
        random.seed(100)

    def tearDown(self):
        print("#" * 30)

    def test_encrypt(self):
        test_count = 0
        for i in range(20):
            message = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" * random.randint(1, 5)
            message = list(message)
            random.shuffle(message)
            message = "".join(message)

            for key in range(1, len(message)):
                encrypted = transpositionEncrypt.encrypt(message, key)
                decrypted = transpositionEncrypt.encrypt(encrypted, math.ceil(len(encrypted)/key))
                # print("message:", message)
                # print("encrypted:", encrypted)
                # print("decrypted", decrypted)
                # print()
                self.assertIn(message, decrypted)
                test_count += 1

        print("test count:", test_count)

        for i in range(10):
            print(random.randint(1, 2))
